사이트 내 전체검색
PHP
utf-8 자동 감지 및 HTML 엔티티로 표현된 문자열 변환 &# ....
로빈아빠
https://cmd.kr/php/815 URL이 복사되었습니다.

본문

if (1 || $check_count++%10==0 || !$is_utf8) {
//$is_utf8=is_utf8($item['title']);
$is_utf8=mb_detect_encoding($item['title']);
$euc_kr=mb_detect_encoding($item['title'],'EUC-KR');
//echo $item['title']," is_utf8:",$is_utf8," euc_kr:$euc_kr<BR>";
//if (!$is_utf8 && !$euc_kr) $is_utf8='UTF-8';
}

if (!$is_utf8) $title = iconv("EUC-KR", "UTF-8", $item['title']); 
else $title = $item['title']; 
//echo "$item[title] --> $title is_utf8:",$is_utf8," euc_kr:$euc_kr<BR>";

$title=htmlspecialchars_decode($title);
$title=preg_replace_callback('/&#[0-9]+;/', 'unichar2', $title);
$title=rawurldecode($title);

$content=htmlspecialchars_decode($content);
$content=preg_replace_callback('/&#[0-9]+;/', 'unichar2', $content);
$content=rawurldecode($content);
//echo "<xmp>$title</xmp><BR>"; continue;

function unichar2($match) {
    return mb_convert_encoding($match[0], 'UTF-8', 'HTML-ENTITIES');
}

댓글목록

등록된 댓글이 없습니다.

PHP
871 (4/18P)

Search

Copyright © Cmd 명령어 3.135.194.251